// part1:C09:ex9.26.cpp
// copy array to vector and list.
#include <iostream>
#include <vector>
#include <list>

int main(void) {
  using namespace std;
  int arr[] = {0, 1, 1, 2, 3, 5, 8, 13, 21, 55, 89};
  vector<int> iv;
  list<int> ilis;

  iv.assign(arr, arr + 11);
  ilis.assign(arr, arr + 11);

  vector<int>::iterator iterv = iv.begin();
  while (iterv != iv.end()) {
    if (!(*iterv & 1))    // even number
      iterv = iv.erase(iterv);
    else
      iterv++;  
  }

  list<int>::iterator ilisv = ilis.begin();
  while (ilisv != ilis.end()) {
    if ((*ilisv & 1) == 1)
      ilisv = ilis.erase(ilisv);
    else
      ilisv++;
  }

  for (iterv = iv.begin(); iterv != iv.end(); iterv++) {
    cout << *iterv << " ";  
  }
  cout << endl;

  for (ilisv = ilis.begin(); ilisv != ilis.end(); ilisv++) {
    cout << *ilisv << " ";
  }
  cout << endl;

  return 0;
}
